<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.19"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Modbus cpp: MB::ModbusRequest Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Modbus cpp
   &#160;<span id="projectnumber">0.1</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.19 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceMB.html">MB</a></li><li class="navelem"><a class="el" href="classMB_1_1ModbusRequest.html">ModbusRequest</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="classMB_1_1ModbusRequest-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">MB::ModbusRequest Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><code>#include &lt;<a class="el" href="modbusRequest_8hpp_source.html">modbusRequest.hpp</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:af3bab6bbf1cc4f57f683878444e09a26"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusRequest.html#af3bab6bbf1cc4f57f683878444e09a26">ModbusRequest</a> (const std::vector&lt; uint8_t &gt; &amp;inputData, bool CRC=false) noexcept(false)</td></tr>
<tr class="memdesc:af3bab6bbf1cc4f57f683878444e09a26"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructs Request from raw data.  <a href="classMB_1_1ModbusRequest.html#af3bab6bbf1cc4f57f683878444e09a26">More...</a><br /></td></tr>
<tr class="separator:af3bab6bbf1cc4f57f683878444e09a26"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9d17929ef7908eb3c36df6d4d1c9b2c6"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusRequest.html#a9d17929ef7908eb3c36df6d4d1c9b2c6">ModbusRequest</a> (uint8_t slaveId=0, <a class="el" href="namespaceMB_1_1utils.html#aa8ebb89b73bf4d0e3485b6341a50f116">utils::MBFunctionCode</a> functionCode=static_cast&lt; <a class="el" href="namespaceMB_1_1utils.html#aa8ebb89b73bf4d0e3485b6341a50f116">utils::MBFunctionCode</a> &gt;(0), uint16_t address=0, uint16_t registersNumber=0, std::vector&lt; <a class="el" href="classMB_1_1ModbusCell.html">ModbusCell</a> &gt; values={}) noexcept</td></tr>
<tr class="separator:a9d17929ef7908eb3c36df6d4d1c9b2c6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4bdf13d31f10bdc3a46c84971458322e"><td class="memItemLeft" align="right" valign="top"><a id="a4bdf13d31f10bdc3a46c84971458322e"></a>
&#160;</td><td class="memItemRight" valign="bottom"><b>ModbusRequest</b> (const <a class="el" href="classMB_1_1ModbusRequest.html">ModbusRequest</a> &amp;)=default</td></tr>
<tr class="separator:a4bdf13d31f10bdc3a46c84971458322e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6d08428234559ffb96e5ef956b859442"><td class="memItemLeft" align="right" valign="top"><a id="a6d08428234559ffb96e5ef956b859442"></a>
std::string&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusRequest.html#a6d08428234559ffb96e5ef956b859442">toString</a> () const noexcept</td></tr>
<tr class="memdesc:a6d08428234559ffb96e5ef956b859442"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns string representation of object. <br /></td></tr>
<tr class="separator:a6d08428234559ffb96e5ef956b859442"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a869361ddbd05931ca0dbcebe688b0cb3"><td class="memItemLeft" align="right" valign="top">std::vector&lt; uint8_t &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusRequest.html#a869361ddbd05931ca0dbcebe688b0cb3">toRaw</a> () const noexcept</td></tr>
<tr class="separator:a869361ddbd05931ca0dbcebe688b0cb3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a22966d0c19bb79c4e8cf03edb5b74a4e"><td class="memItemLeft" align="right" valign="top"><a id="a22966d0c19bb79c4e8cf03edb5b74a4e"></a>
<a class="el" href="namespaceMB_1_1utils.html#a0b3590994f5ba26cd61929f5a394ab70">utils::MBFunctionType</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusRequest.html#a22966d0c19bb79c4e8cf03edb5b74a4e">functionType</a> () const noexcept</td></tr>
<tr class="memdesc:a22966d0c19bb79c4e8cf03edb5b74a4e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns function type based on Modbus function code. <br /></td></tr>
<tr class="separator:a22966d0c19bb79c4e8cf03edb5b74a4e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8097a0866398cef7f1244ca7ca412062"><td class="memItemLeft" align="right" valign="top"><a id="a8097a0866398cef7f1244ca7ca412062"></a>
<a class="el" href="namespaceMB_1_1utils.html#a8098c5bcb6c33b219bafdee42334e260">utils::MBFunctionRegisters</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classMB_1_1ModbusRequest.html#a8097a0866398cef7f1244ca7ca412062">functionRegisters</a> () const noexcept</td></tr>
<tr class="memdesc:a8097a0866398cef7f1244ca7ca412062"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns register type based on Modbus function code. <br /></td></tr>
<tr class="separator:a8097a0866398cef7f1244ca7ca412062"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9cf13a29c9716ea32c54c7a218fb0b64"><td class="memItemLeft" align="right" valign="top"><a id="a9cf13a29c9716ea32c54c7a218fb0b64"></a>
uint8_t&#160;</td><td class="memItemRight" valign="bottom"><b>slaveID</b> () const</td></tr>
<tr class="separator:a9cf13a29c9716ea32c54c7a218fb0b64"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a871e5bb330d4788af84bf79c47da4332"><td class="memItemLeft" align="right" valign="top"><a id="a871e5bb330d4788af84bf79c47da4332"></a>
<a class="el" href="namespaceMB_1_1utils.html#aa8ebb89b73bf4d0e3485b6341a50f116">utils::MBFunctionCode</a>&#160;</td><td class="memItemRight" valign="bottom"><b>functionCode</b> () const</td></tr>
<tr class="separator:a871e5bb330d4788af84bf79c47da4332"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab78354ea2ad390575c0479235104e424"><td class="memItemLeft" align="right" valign="top"><a id="ab78354ea2ad390575c0479235104e424"></a>
uint16_t&#160;</td><td class="memItemRight" valign="bottom"><b>registerAddress</b> () const</td></tr>
<tr class="separator:ab78354ea2ad390575c0479235104e424"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aae5ff9dea983484aee439e0fccc3d406"><td class="memItemLeft" align="right" valign="top"><a id="aae5ff9dea983484aee439e0fccc3d406"></a>
uint16_t&#160;</td><td class="memItemRight" valign="bottom"><b>numberOfRegisters</b> () const</td></tr>
<tr class="separator:aae5ff9dea983484aee439e0fccc3d406"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8f9e8d364ce553dd809da6adea96ae9d"><td class="memItemLeft" align="right" valign="top"><a id="a8f9e8d364ce553dd809da6adea96ae9d"></a>
const std::vector&lt; <a class="el" href="classMB_1_1ModbusCell.html">ModbusCell</a> &gt; &amp;&#160;</td><td class="memItemRight" valign="bottom"><b>registerValues</b> () const</td></tr>
<tr class="separator:a8f9e8d364ce553dd809da6adea96ae9d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a446b1787c883aa2d5b3a692e3f9cd087"><td class="memItemLeft" align="right" valign="top"><a id="a446b1787c883aa2d5b3a692e3f9cd087"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>setSlaveId</b> (uint8_t slaveId)</td></tr>
<tr class="separator:a446b1787c883aa2d5b3a692e3f9cd087"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a69a5649168768e27a3ae24fe7850d6ea"><td class="memItemLeft" align="right" valign="top"><a id="a69a5649168768e27a3ae24fe7850d6ea"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>setFunctionCode</b> (<a class="el" href="namespaceMB_1_1utils.html#aa8ebb89b73bf4d0e3485b6341a50f116">utils::MBFunctionCode</a> functionCode)</td></tr>
<tr class="separator:a69a5649168768e27a3ae24fe7850d6ea"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a33e2dd3c3f74e8be2dc78c9e89480df7"><td class="memItemLeft" align="right" valign="top"><a id="a33e2dd3c3f74e8be2dc78c9e89480df7"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>setAddress</b> (uint16_t address)</td></tr>
<tr class="separator:a33e2dd3c3f74e8be2dc78c9e89480df7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab876cc3045610c29092145cb62422fa7"><td class="memItemLeft" align="right" valign="top"><a id="ab876cc3045610c29092145cb62422fa7"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>setRegistersNumber</b> (uint16_t registersNumber)</td></tr>
<tr class="separator:ab876cc3045610c29092145cb62422fa7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3c0127e64f358266ebc1e9d24eea60fc"><td class="memItemLeft" align="right" valign="top"><a id="a3c0127e64f358266ebc1e9d24eea60fc"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><b>setValues</b> (const std::vector&lt; <a class="el" href="classMB_1_1ModbusCell.html">ModbusCell</a> &gt; &amp;values)</td></tr>
<tr class="separator:a3c0127e64f358266ebc1e9d24eea60fc"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:a408dad848ae2e8bac479b574464113ab"><td class="memItemLeft" align="right" valign="top"><a id="a408dad848ae2e8bac479b574464113ab"></a>
static <a class="el" href="classMB_1_1ModbusRequest.html">ModbusRequest</a>&#160;</td><td class="memItemRight" valign="bottom"><b>fromRaw</b> (const std::vector&lt; uint8_t &gt; &amp;inputData) noexcept(false)</td></tr>
<tr class="separator:a408dad848ae2e8bac479b574464113ab"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9c5c438f8d3c2cf6951d398b6d034004"><td class="memItemLeft" align="right" valign="top"><a id="a9c5c438f8d3c2cf6951d398b6d034004"></a>
static <a class="el" href="classMB_1_1ModbusRequest.html">ModbusRequest</a>&#160;</td><td class="memItemRight" valign="bottom"><b>fromRawCRC</b> (const std::vector&lt; uint8_t &gt; &amp;inputData)</td></tr>
<tr class="separator:a9c5c438f8d3c2cf6951d398b6d034004"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>This class represent Modbus response, it allows user to manipulate and display it in various ways. </p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="af3bab6bbf1cc4f57f683878444e09a26"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af3bab6bbf1cc4f57f683878444e09a26">&#9670;&nbsp;</a></span>ModbusRequest() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">ModbusRequest::ModbusRequest </td>
          <td>(</td>
          <td class="paramtype">const std::vector&lt; uint8_t &gt; &amp;&#160;</td>
          <td class="paramname"><em>inputData</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>CRC</em> = <code>false</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Constructs Request from raw data. </p>
<dl class="section note"><dt>Note</dt><dd>1) if CRC = true input data needs to contain 2 CRC bytes on back (used in RS) </dd>
<dd>
2) This is private constructor, you need to use fromRaw or fromRawCRC </dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">inputData</td><td>- Is vector of bytes that will be be interpreted, whereas based on CRC parameter method performs CRC calculation and throws exception if it is invalid </td></tr>
  </table>
  </dd>
</dl>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname"><a class="el" href="classMB_1_1ModbusException.html">ModbusException</a></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="a9d17929ef7908eb3c36df6d4d1c9b2c6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9d17929ef7908eb3c36df6d4d1c9b2c6">&#9670;&nbsp;</a></span>ModbusRequest() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">ModbusRequest::ModbusRequest </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>slaveId</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="namespaceMB_1_1utils.html#aa8ebb89b73bf4d0e3485b6341a50f116">utils::MBFunctionCode</a>&#160;</td>
          <td class="paramname"><em>functionCode</em> = <code>static_cast&lt;<a class="el" href="namespaceMB_1_1utils.html#aa8ebb89b73bf4d0e3485b6341a50f116">utils::MBFunctionCode</a>&gt;(0)</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>address</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>registersNumber</em> = <code>0</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">std::vector&lt; <a class="el" href="classMB_1_1ModbusCell.html">ModbusCell</a> &gt;&#160;</td>
          <td class="paramname"><em>values</em> = <code>{}</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">explicit</span><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Simple constructor, that allows to create "dummy" <a class="el" href="classMB_1_1ModbusResponse.html">ModbusResponse</a> object. May be useful in some cases. </p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a869361ddbd05931ca0dbcebe688b0cb3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a869361ddbd05931ca0dbcebe688b0cb3">&#9670;&nbsp;</a></span>toRaw()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">std::vector&lt; uint8_t &gt; ModbusRequest::toRaw </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Returns raw bytes representation of object, ready for modbus communication </p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>include/MB/<a class="el" href="modbusRequest_8hpp_source.html">modbusRequest.hpp</a></li>
<li>src/modbusRequest.cpp</li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.8.19
</small></address>
</body>
</html>
